package Leetcode.lc160;

import Leetcode.tools.ListNode;

/***
 *
 */
public class Sloution {
    /***
     * 双指针
     * @param headA
     * @param headB
     * @return
     */
    public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
        ListNode p=headA,q=headB;
        while(p!=q){
            if(p!=null) p=p.next;
            else p=headB;
            if(q!=null) q=q.next;
            else q=headA;
        }
        return p;
    }

    public static void main(String[] args) {

    }
}
